<template>
  <div class="app-container" style="text-align: center">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="申请人" width="95">
        <template slot-scope="scope">
          {{ username }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="申报奖项">
        <template slot-scope="scope">
          {{ scope.row.awardName }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="审批单位">
        <template slot-scope="scope">
          <span>{{ scope.row.organizationId }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="申请状态" width="200" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.status }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  import {CLASSID_KEY, organizationMap, ROLE_KEY, UNAME_KEY} from "../../constants";
  import {addOneNotice, getNoticeListByClassid} from "../../api";
  import {formatTime} from "../../utils/timeFormat";
  import {studentApplicationQuery} from "../../api/student";

  export default {
    name: 'ApplyList',
    data() {
      return {
        addInput: '',
        list: null,
        listLoading: true,
        role: localStorage.getItem(ROLE_KEY),
        username: localStorage.getItem(UNAME_KEY)
      }
    },
    methods: {
      formatTime: formatTime,
      checkDetail(id) {
        this.$router.push({ path: '/notice/detail/' + id })
      },
    },
    mounted() {
      this.listLoading = true
      studentApplicationQuery().then(res => {
        // this.list = res.data;
        let data = res.data;
        for(let i = 0; i < data.length; ++i) {
          data[i].organizationId = organizationMap[data[i].organizationId.toString()]
        }
        this.list = data
        this.listLoading = false
        console.log(res.data)
      })
    }
  }
</script>
